from math import radians, cos, sin, asin, sqrt

# FORMULA USED TO CALCULATE DISTANCES

def geodesic(lat1,lon1,lat2,lon2):

    # convert decimal degrees to radians 

    lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])

    # geodesic formula 

    dlon = lon2 - lon1 
    dlat = lat2 - lat1 
    a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
    c = 2 * asin(sqrt(a)) 

    r = 6371

    return(c*r)

if __name__ == "__main__":

    lat1,lon1 = 38.94, -77.07
    lat2,lon2 = 38.89, -77.01
    
    print(geodesic(lat1,lon1,lat2,lon2))